package com.blyat.xsoft.gateway.ribbon.filter.global;

import com.blyat.xsoft.gateway.ribbon.filter.FilterOrder;
import com.blyat.xsoft.kernel.util.StringUtil;
import org.springframework.cloud.gateway.filter.GatewayFilterChain;
import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.core.Ordered;
import org.springframework.http.HttpHeaders;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.web.server.ServerWebExchange;
import reactor.core.publisher.Mono;

/**
 * @Auther: syh
 * @Date: 2020/8/27
 * @Description:
 */
public class AuthenticationFilter implements GlobalFilter, Ordered {

    private static final String TOKEN_KEY = "Authorization";

    @Override
    public int getOrder() {
        return FilterOrder.GLOBAL_AUTHENTICATION_ORDER;
    }

    @Override
    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
        ServerHttpRequest request = exchange.getRequest();
        String header = request.getHeaders().getFirst(HttpHeaders.AUTHORIZATION);
        if (StringUtil.isNotBlank(header)) {

        }
        return null;
    }
}
